@extends('layouts.back_stage')
@section('content')
  <style>
   [v-cloak] {display: none;}
   .back{background:#fff;margin:20px;padding:10px}
   .type_x{margin:20px 0 0 20px;}
   .ingred_sel{width:200px;margin-right:10px}
   .add_s{margin:20px 0 0 20px}
   .addsert{font-weight:500;margin:20px 0 0 30px}
   .disscount{margin:20px 0 40px 20px;}
   .input_disscount{width:200px;margin-right:40px}
   .tab_show{margin:10px 0 20px 20px}
   .form_t{margin-left:40px}
   .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .input_rate{width:140px}
  .el-upload__input{opacity:0}
  .rest{margin:10px 0 0 40px}
  </style>
    <div class="container">
       <div class="page-body" id="app" v-cloak>
         <el-form  ref="ruleForm" v-model="ruleForm"   class="demo-ruleForm">
              <div class="header"><h3>客户基本信息</h3></div>
              <div class="back">
                <div class="type_x">
                    <label>客户类型：</label>
                    <el-select  size="small" v-model="clien.type" class="ingred_sel" @change="typeValue">
                        <el-option :value="1" label="分公司">分公司</el-option>
                        <el-option :value="2" label="代理商">代理商</el-option>
                        <el-option :value="3" label="客户">客户</el-option>
                    </el-select>
                    <label>客户名称：</label>
                       <el-input  class="ingred_sel" v-model="clien.name"  maxlength="10"   size="small" placeholder="请输入"></el-input>
                    <label>手机号码：</label>
                       <el-input  class="ingred_sel" v-model="clien.tel" size="small" placeholder="请输入手机号"></el-input>
                  </div>
                  <div class="type_x">
                      <label>所属机构：</label>
                      <el-cascader style="width:500px;" :options="companyList" v-model="company_id" :change-on-select="true" size="small"></el-cascader>
                  </div>
                  <div class="add_s">
                    <label>省 市 区：</label>
                        <el-cascader style="width:500px;margin-left: 5px;" :options="options"  class='caser' size="small" change-on-select v-model="clien.area" @focus="handleChange"></el-cascader>
                  </div>
                  <div class="addsert">
                      <label>地 址:</label>
                          <el-input style="width:500px;margin-left: 23px;" class="input_add on" maxlength="30" v-model="clien.address" size="small" placeholder="请输入地址"></el-input>
                  </div>
                  <div class="disscount">
                    <label>默认拿货折扣：</label>
                        <el-input  class="input_disscount on" v-model="clien.discount_default" size="small" maxlength="5" placeholder="请输入0-1之间的数"></el-input>
                          <!-- <label>店铺系统:</label>
                          <el-checkbox label="不开通" v-model="checked"></el-checkbox>
                          <el-checkbox label="直营店" disabled></el-checkbox>
                          <el-checkbox label="联营店" disabled></el-checkbox>
                          <el-checkbox label="加盟店" disabled></el-checkbox>
                          <el-checkbox label="折扣店" disabled></el-checkbox> -->
                  </div>
              </div>
              <div class="font_a"><h3>政策信息</h3></div>
                  <div class="back">
                      <el-tabs type="border-card"   v-model="formrole"   :before-leave="tabsBefore"  @tab-click="tabsform" >
                          <el-tab-pane  v-for=" itme in opt" :label=`${itme.name}` :key="itme.textId"     :name=`${itme.textId}`>
                                 <div class="tab_show" >
                                    <label>折扣：</label>
                                    <el-input  class="input_disscount on"  maxlength="4"  @blur="blur0()" v-model="ruleForm.policy_discount" size="small" placeholder="请输入0-1之间的数"></el-input>
                                  </div>
                                  <div class="sales">
                                        <h4>退货率：</h4>
                                        <el-form :inline="true"  class="demo-form-inline form_t">
                                                <div>
                                                  <el-form-item label="第一季度：">
                                                    <el-input v-model="ruleForm.first_rate"  class="input_rate" @blur="blur1()" maxlength="5" size="small" placeholder="请输入0-100的数"></el-input> %
                                                  </el-form-item>
                                                  <el-form-item label="退货期限： 选择日期">
                                                      <el-date-picker v-model="ruleForm.first_daterange"  @blur="blur11"  type="daterange"  size="small" value-format="yyyy-MM-dd " range-separator="至"  start-placeholder="开始日期" end-placeholder="结束日期"> </el-date-picker>
                                                  </el-form-item>
                                              </div>
                                              <div>
                                                  <el-form-item label="第二季度：">
                                                    <el-input v-model="ruleForm.second_rate" size="small"   class="input_rate" @blur="blur2"  maxlength="5"  placeholder="请输入0-100的数"></el-input>%
                                                  </el-form-item>
                                                  <el-form-item label="退货期限： 选择日期">
                                                      <el-date-picker v-model="ruleForm.second_daterange"   @blur="blur21" type="daterange" value-format="yyyy-MM-dd "  size="small"  range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"> </el-date-picker>
                                                  </el-form-item>
                                              </div>
                                              <div>
                                                  <el-form-item label="第三季度：">
                                                    <el-input v-model="ruleForm.third_rate" size="small"   class="input_rate" @blur="blur3" maxlength="5" placeholder="请输入0-100的数"></el-input>%
                                                  </el-form-item>
                                                  <el-form-item label="退货期限： 选择日期">
                                                      <el-date-picker v-model="ruleForm.third_daterange"  @blur="blur31" type="daterange"  size="small"  value-format="yyyy-MM-dd " range-separator="至"   start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
                                                  </el-form-item>
                                              </div>
                                              <div>
                                                  <el-form-item label="第四季度：">
                                                    <el-input v-model="ruleForm.fourth_rate" size="small"   class="input_rate"  @blur="blur4" maxlength="5" placeholder="请输入0-100的数"></el-input>%
                                                  </el-form-item>
                                                  <el-form-item label="退货期限： 选择日期">
                                                      <el-date-picker v-model="ruleForm.fourth_daterange"   @blur="blur41" type="daterange"  size="small"  value-format="yyyy-MM-dd " range-separator="至"   start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
                                                  </el-form-item>
                                              </div>
                                              <div>
                                                  <el-form-item label="全年总数：">
                                                    <el-input v-model="ruleForm.year_rate" size="small"   class="input_rate"  @blur="blur5" maxlength="5" placeholder="请输入0-100的数"></el-input>%
                                                  </el-form-item>
                                                  <el-form-item label="退货期限： 选择日期">
                                                      <el-date-picker v-model="ruleForm.year_daterange" type="daterange"   @blur="blur51" size="small"  value-format="yyyy-MM-dd" range-separator="至"   start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
                                                  </el-form-item>
                                              </div>
                                        </el-form>
                                      </div>  
                              </el-tab-pane>
                          </el-tabs>         
                  </div>
               <div class="font_a"><h3>合同管理</h3></div>  
                 <div class="back">
                    <p>协议附件</p>
                    <el-upload
                        action="/clients/uploadagreement"
                        list-type="picture-card"
                        name="agreement"
                        :on-preview="handlePictureCardPreview"
                        :on-success="successFile"
                        :before-upload="beforeAvatarUpload"
                        :on-remove="handleRemove">
                        <i class="el-icon-plus"></i>
                    </el-upload>
                    <el-dialog :visible.sync="dialogVisible">
                        <img width="100%" :src="dialogImageUrl" alt="">
                    </el-dialog>
                    <span style="color:#ccc">上传图片必须是JPG/PNG 格式  且不大于2M</span>
                        <input  type="hidden" name="agreement"/>
                </div>  
                <el-form-item>
                    <el-button type="primary" class="rest" size="small" @click="formSubmit" :disabled="isSub">立即创建</el-button>
                    <el-button type="primary" size="small" @click="resetForm">重置</el-button>
                </el-form-item>
         </el-form>
      </div>
    </div>
 <script>
   var App=new Vue({
        el: '#app',
        data() {
          return {
              clien:{
                type:'',
                name:'',
                tel:'',
                pid:'',
                area:[],
                area_bh:'',
                address:'',
                discount_default:'',
                agreement:'',
               
              },
               
              ruleForm:{
                // type:'',
                // name:'',
                // tel:'',
                // pid:'',
                // area:[],
                // area_bh:'',
                // address:'',
                // discount_default:'',
                policy_discount:'',
                first_rate:'',
                first_daterange:'',
                second_rate:'',
                second_daterange:'',
                third_rate:'',
                third_daterange:'',
                fourth_rate:'',
                fourth_daterange:'',
                year_rate:'',
                year_daterange:'',               
              },
              policies:{},
              companyList:[],//机构下拉
              company_id:[],//机构下拉
              options: [],//省市区'
              formrole:'',//tabs切换
              opt:[],//政策里面的机构按钮的发货类型
              agreement:'',//图片上传
              dialogVisible: false,//图片上传
              dialogImageUrl: '',//图片上传
              wq:{
                  name:'a',
                  type:'b'
                },
                isSub:false,
                valType:'',
                text:'',
                first:'',
                second:'',
                third:'',
                fourth:'',
                year:'',
                first1:[],
                second1:[],
                third1:[],
                fourth1:[],
                year1:[],
                lock:false,
            }
          },
       methods: {
        blur(){
               this.policies[this.valType] = this.ruleForm
        },
        blur0(){
       
            if(this.ruleForm.policy_discount!='' |this.ruleForm.policy_discount!=null){
                    var rest=/^(0\.\d{1,2}|1(\.0{1,2})?)$/;           
                    if(!rest.test(this.ruleForm.policy_discount)){
                        this.$notify.error({
                                title: '提示',
                                message: '请输入0-1之间的两位数折扣',
                            });
                            return false;
                        }
               }
     if(this.ruleForm.policy_discount=='' &&  his.ruleForm.first_rate==' ' &&  this.ruleForm.second_rate=='' && this.ruleForm.third_rate=='' && this.ruleForm.fourth_rate=='' && this.ruleForm.year_rate==''){
         return
     }
            this.blur()
        },
        blur1(){
            
           this.blur()
        },
        blur2(){
        
           this.blur()
         },
        blur3(){
           
              this.blur()
        },
        blur4(){
            
              this.blur()
        },
        blur5(){
            
               this.blur()
        },
        blur11(){
            this.blur()
        },
        blur21(){
          
              this.blur()
        },
        blur31(){
            this.blur()
        },
        blur41(){
           
               this.blur()
        },
        blur51(){
         
              this.blur() 
        },
         //类型点击之后
            typeValue(val){
              this.ruleForm.type=val
            },
          //所属机构
          getCompanyList(){
           let that=this
           let list=[]
                $.ajax({
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content'),
                        'contentType':'application/json'
                    },
                    url: '/clients/getall',
                    type: 'get',
                    dataType: 'json',
                    success:res=>{
                        if(res.result.success){
                            for(let value of res.content[1]){
                                value['value'] = value.id
                                value['label'] = value.company_name
                                let child_data = res.content[1].filter((n) => n.pid == value.id && n.id != value.id)
                                if(child_data.length > 0){
                                    value['children'] = child_data
                                }
                            }
                            this.companyList = res.content[1].filter((n) => n.id == res.content[0])
                        }else{
                            this.$notify.error({
                                title: '错误',
                                message: res.result.errorMsg
                            })
                        }
                     }
                 })
              },  
             //这是三级联动的 省市区
            handleChange(value) {
              const that=this;
              $.ajax({
                headers: { 'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')},
                type:'get',
                url:'/clients/address'
              }).then(function(response){
                let data=response
                const options = [];
                for (let item in data) {
                  let province = {
                          value: data[item].value,
                          label: data[item].label,
                          children: []
                      };
                      for (let city in data[item].children) {
                        let counties=[];
                        for (let county in data[item].children[city].children) {
                              let cityno=data[item].children[city].children[county];
                              counties.push({value:cityno.value,label:cityno.label});
                          }
                          province.children.push({
                              value: data[item].children[city].value,
                              label: data[item].children[city].label,
                              children:counties
                          });
                      }
                          options.push(province)
                    }
                    that.$data.options=options;
               })  
            },
             //  tabs 切换认证是否通过
             tabsBefore(activeName, oldActiveName){
                let prev = this.formrole
            let that=this
            this.lock=false
            if(that.ruleForm.first_rate != null && that.ruleForm.first_rate != ''){
                        if(that.ruleForm.first_daterange == '' || that.ruleForm.first_daterange == null || that.ruleForm.first_daterange.length < 2){
                            this.$notify.error({
                                title: '提示',
                                message: '政策信息第一季度填写有误',
                            });
                            this.lock = true
                        }
                    }
                    if(that.ruleForm.first_daterange != '' && that.ruleForm.first_daterange != null && that.ruleForm.first_daterange.length == 2){
                        if(that.ruleForm.first_rate  == '' || that.ruleForm.first_rate == null){
                            this.$notify.error({
                                title: '提示',
                                message: '政策信息第一季度填写有误',
                            });
                            this.lock = true 
                        }
                    }
                    if(that.ruleForm.second_rate != null && that.ruleForm.second_rate != ''){
                        if(that.ruleForm.second_daterange == '' || that.ruleForm.second_daterange == null || that.ruleForm.second_daterange.length < 2){
                            this.$notify.error({
                                title: '提示',
                                message: '政策信息第二季度填写有误',
                            })
                            this.lock = true
                        }
                    }
                    if(that.ruleForm.second_daterange != '' && that.ruleForm.second_daterange != null && that.ruleForm.second_daterange.length == 2){
                        if(that.ruleForm.second_rate  == '' || that.ruleForm.second_rate == null){
                            this.$notify.error({
                                title: '提示',
                                message: '政策信息第二季度填写有误',
                            });
                            this.lock = true  
                        }
                    }
                    if(that.ruleForm.third_rate != null && that.ruleForm.third_rate != ''){
                        if(that.ruleForm.third_daterange == '' || that.ruleForm.third_daterange == null || that.ruleForm.third_daterange.length < 2){
                            this.$notify.error({
                                title: '提示',
                                message: '政策信息第三季度填写有误',
                            })
                            this.lock = true
                        }
                    }
                    if(that.ruleForm.third_daterange != '' && that.ruleForm.third_daterange != null && that.ruleForm.third_daterange.length == 2){
                        if(that.ruleForm.third_rate  == '' || that.ruleForm.third_rate == null){
                            this.$notify.error({
                                title: '提示',
                                message: '政策信息第三季度填写有误',
                            });
                            this.lock = true
                        }
                    }
                    if(that.ruleForm.fourth_rate != null && that.ruleForm.fourth_rate != ''){
                        if(that.ruleForm.fourth_daterange == '' || that.ruleForm.fourth_daterange == null || that.ruleForm.fourth_daterange.length < 2){
                            this.$notify.error({
                                title: '提示',
                                message: '政策信息第四季度填写有误',
                            })
                            this.lock = true
                        }
                    }
                    if(that.ruleForm.fourth_daterange != '' && that.ruleForm.fourth_daterange != null && that.ruleForm.fourth_daterange.length == 2){
                        if(that.ruleForm.fourth_rate  == '' || that.ruleForm.fourth_rate == null){
                            this.$notify.error({
                                title: '提示',
                                message: '政策信息第四季度填写有误',
                            });
                            this.lock = true
                        }
                    }
                    if(that.ruleForm.year_rate != null && that.ruleForm.year_rate != ''){
                        if(that.ruleForm.year_daterange == '' || that.ruleForm.year_daterange == null || that.ruleForm.year_daterange.length < 2){
                            this.$notify.error({
                                title: '提示',
                                message: '政策信息全年季度填写有误',
                            })
                            this.lock = true 
                        }
                    }
                    if(that.ruleForm.year_daterange != '' && that.ruleForm.year_daterange != null && that.ruleForm.year_daterange.length == 2){
                        if(that.ruleForm.year_rate  == '' || that.ruleForm.year_rate == null){
                            this.$notify.error({
                                title: '提示',
                                message: '政策信息全年季度填写有误',
                            });
                            this.lock = true
                        }
                    }
                    if(this.lock){
                        return false
                    }
              },
             //点击tabs
          tabsform(val){
            let that=this
            if(this.lock){
                
                return false
            }
            that.valType=val.name//当前点击的id
            
            if(this.policies[val.name] == undefined || this.policies[val.name] == null){
               //重置ruleform
                let list = {
                    type:val.name,
                    policy_discount:'',
                    first_rate:'',
                    second_rate:'',
                    third_rate:'',
                    fourth_rate:'',
                    year_rate:'',
                    first_daterange:'',
                    second_daterange:'',
                    third_daterange:'',
                    fourth_daterange:'',
                    year_daterange:'',
                }
                this.ruleForm = list
                if(that.ruleForm.policy_discount!=''){
                 var rest=/^(0\.\d{1,2}|1(\.0{1,2})?)$/;           
                  if(!rest.test(that.ruleForm.policy_discount)){
                        that.$notify.error({
                                title: '提示',
                                message: '政策信息折扣有误，请输入0-100的数字',
                            });
                            return false;
                        }
                    }
                    return
                }
                let list = this.policies[val.name]
                this.ruleForm = list
            },

            request(){  //政策里面的发货类型
                let that=this
                let textId=''
                let list=[]
                $.ajax({
                  type:'get',
                  url:'/deliver/index'
                }).then(function(res){
                    for(var x in res.content){
                      list.push({
                        textId:res.content[x].id,
                        name:res.content[x].name
                      })
                    }
                    that.opt=list
                })
            }, 
            handlePictureCardPreview(file) {//已上传的文件时的钩子
                  this.dialogImageUrl = file.url;
                  this.dialogVisible = true;
              },
            successFile(response, file, fileList){//上传成功时的文件时的钩子
                let that=this
                for(var e in fileList){
                 this.clien.agreement=fileList[e].response.content
                 this.agreement=fileList[e].response.content
                }
              }, 
            beforeAvatarUpload(file) { //上传图片是限制格式
                const isJPG = file.type === 'image/jpeg';
                const isPNG = file.type === 'image/png';
                const isLt2M = file.size / 1024 / 1024 < 2;
                if (!isJPG &&  !isPNG ) {
                this.$notify({
                        title: '警告',
                        message: '上传图片必须是JPG/PNG/BMP 格式!',
                        type: 'warning'
                        });
                return false;
                }
                if (!isLt2M) {
                    this.$notify({
                        title: '警告',
                        message: '上传头像图片大小不能超过 2MB!',
                        type: 'warning'
                        });
                    return false;
                }
                return (isJPG || isPNG )&& isLt2M;
             }, 
            handleRemove(file, fileList) {//移除文件时的钩子

            },
              //重置清空
          resetForm(){
                this.ruleForm.type=''
                this.ruleForm.pid=''
                this.ruleForm.name=''
                this.ruleForm.tel=''
                this.ruleForm.address=''
                this.ruleForm.discount_default=''
                this.ruleForm.type_form=''
                this.ruleForm.policy_discount=''
                this.ruleForm.first_rate=''
                this.ruleForm.second_rate=''
                this.ruleForm.third_rate=''
                this.ruleForm.fourth_rate=''
                this.ruleForm.year_rate=''
                this.ruleForm.first_daterange=''
                this.ruleForm.second_daterange=''
                this.ruleForm.third_daterange=''
                this.ruleForm.fourth_daterange=''
                this.ruleForm.year_daterange=''
                this.ruleForm.policy_type=''
                this.ruleForm.area_bh=''
                this.company_id=[]
                this.fileList=[]
                this.ruleForm.area=[]
                    this.$notify({
                        title: '成功',
                        message: '重置清空成功',
                        type: 'success'
                    });
            },
           //提交
            formSubmit(){
                let that=this
                if(this.clien.type==''){
                    this.$notify.error({
                            title: '提示',
                            message: '请选择客户类型',
                        });
                        return false;
                    }
                    if(this.clien.name==''){
                  this.$notify.error({
                        title: '提示',
                        message: '请输入客户名',
                    });
                    return false;
                    }
                    if(this.clien.tel==''){
                        this.$notify.error({
                                title: '提示',
                                message: '请输入手机号码',
                            });
                            return false;
                        }
                        var moder=/^1[3-9]\d{9}$/
                        if(!moder.test(this.clien.tel)){
                            this.$notify.error({
                                title: '提示',
                                message: '手机号码格式有问题，请输入正确的号码',
                            });
                            return false;
                        }
                    this.clien.pid=this.company_id[this.company_id.length-1]
                    if(this.clien.pid==null){
                        this.$notify.error({
                                title: '提示',
                                message: '请选择所属机构',
                            });
                            return false;
                        }
                        if(this.clien.area==undefined){
                            this.$notify.error({
                                    title: '提示',
                                    message: '请选择省市区',
                                });
                                return false;
                        }
                        this.clien.area_bh=this.clien.area[this.clien.area.length-1]
                        if(this.clien.address==''){
                        this.$notify.error({
                                title: '提示',
                                message: '请输入详细地址',
                            });
                            return false;
                        }
                        if(this.clien.discount_default==''){
                        this.$notify.error({
                                title: '提示',
                                message: '请输入默认折扣',
                            });
                            return false;
                        } 
                    var list=/^(0\.\d{1,2}|1(\.0{1,2})?)$/;           
                    if(!list.test(this.clien.discount_default)){
                        this.$notify.error({
                                title: '提示',
                                message: '请输入0-1之间的两位数折扣',
                            });
                            return false;
                        }
                    if(this.ruleForm.policy_discount!=''){
                        var rest=/^(0\.\d{1,2}|1(\.0{1,2})?)$/;           
                        if(!rest.test(this.ruleForm.policy_discount)){
                            this.$notify.error({
                                    title: '提示',
                                    message: '请输入0-1之间的数折扣',
                                });
                                return false;
                            }
                        }
              
                   for(var i in that.policies){
                        if(that.policies[i].policy_discount!=''){
                              var rest=/^(0\.\d{1,2}|1(\.0{1,2})?)$/;           
                                if(!rest.test(that.policies[i].policy_discount)){
                                    that.$notify.error({
                                            title: '提示',
                                            message: '政策信息折扣有误，请输入0-100的数字',
                                        });
                                        return false;
                                    }
                          }
                   }
              
                   if(that.ruleForm.first_rate != null && that.ruleForm.first_rate != ''){
                        if(that.ruleForm.first_daterange == '' || that.ruleForm.first_daterange == null || that.ruleForm.first_daterange.length < 2){
                            this.$notify.error({
                                title: '提示',
                                message: '政策信息第一季度填写有误',
                            });
                            return false  
                        }
                    }
                    if(that.ruleForm.first_daterange != '' && that.ruleForm.first_daterange != null && that.ruleForm.first_daterange.length == 2){
                        if(that.ruleForm.first_rate  == '' || that.ruleForm.first_rate == null){
                            this.$notify.error({
                                title: '提示',
                                message: '政策信息第一季度填写有误',
                            });
                            return false  
                        }
                    }
                    if(that.ruleForm.second_rate != null && that.ruleForm.second_rate != ''){
                        if(that.ruleForm.second_daterange == '' || that.ruleForm.second_daterange == null || that.ruleForm.second_daterange.length < 2){
                            this.$notify.error({
                                title: '提示',
                                message: '政策信息第二季度填写有误',
                            })
                            return false  
                        }
                    }
                    if(that.ruleForm.second_daterange != '' && that.ruleForm.second_daterange != null && that.ruleForm.second_daterange.length == 2){
                        if(that.ruleForm.second_rate  == '' || that.ruleForm.second_rate == null){
                            this.$notify.error({
                                title: '提示',
                                message: '政策信息第二季度填写有误',
                            });
                            return false  
                        }
                    }
                    if(that.ruleForm.third_rate != null && that.ruleForm.third_rate != ''){
                        if(that.ruleForm.third_daterange == '' || that.ruleForm.third_daterange == null || that.ruleForm.third_daterange.length < 2){
                            this.$notify.error({
                                title: '提示',
                                message: '政策信息第三季度填写有误',
                            })
                            return false  
                        }
                    }
                    if(that.ruleForm.third_daterange != '' && that.ruleForm.third_daterange != null && that.ruleForm.third_daterange.length == 2){
                        if(that.ruleForm.third_rate  == '' || that.ruleForm.third_rate == null){
                            this.$notify.error({
                                title: '提示',
                                message: '政策信息第三季度填写有误',
                            });
                            return false  
                        }
                    }
                    if(that.ruleForm.fourth_rate != null && that.ruleForm.fourth_rate != ''){
                        if(that.ruleForm.fourth_daterange == '' || that.ruleForm.fourth_daterange == null || that.ruleForm.fourth_daterange.length < 2){
                            this.$notify.error({
                                title: '提示',
                                message: '政策信息第四季度填写有误',
                            })
                            return false  
                        }
                    }
                    if(that.ruleForm.fourth_daterange != '' && that.ruleForm.fourth_daterange != null && that.ruleForm.fourth_daterange.length == 2){
                        if(that.ruleForm.fourth_rate  == '' || that.ruleForm.fourth_rate == null){
                            this.$notify.error({
                                title: '提示',
                                message: '政策信息第四季度填写有误',
                            });
                            return false  
                        }
                    }
                    if(that.ruleForm.year_rate != null && that.ruleForm.year_rate != ''){
                        if(that.ruleForm.year_daterange == '' || that.ruleForm.year_daterange == null || that.ruleForm.year_daterange.length < 2){
                            this.$notify.error({
                                title: '提示',
                                message: '政策信息全年季度填写有误',
                            })
                            return false  
                        }
                    }
                    if(that.ruleForm.year_daterange != '' && that.ruleForm.year_daterange != null && that.ruleForm.year_daterange.length == 2){
                        if(that.ruleForm.year_rate  == '' || that.ruleForm.year_rate == null){
                            this.$notify.error({
                                title: '提示',
                                message: '政策信息全年季度填写有误',
                            });
                            return false  
                        }
                    }
                   that.isSub=true;
                    $.ajax({
                      headers: { 'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')},
                      type:"post",
                      url:"/clients/store",
                      data:{
                        name:this.clien.name,
                        type:this.clien.type,
                        tel:this.clien.tel,
                        pid:this.clien.pid,
                        address:this.clien.address,
                        discount_default:this.clien.discount_default,
                         area_bh:this.clien.area_bh,
                         agreement:this.clien.agreement,
                        //ruleForm : this.ruleForm,
                        policies : this.policies
                      },
                      success: function (res) {
                        if(res.result.success==true){
                           that.$notify.success({
                                  title: '提示',
                                  message: '创建提交成功',
                              });
                              window.location.href = "/clients/index"; 
                              that.isSub=false;
                         }else{
                            that.$notify.error({
                                  title: '错误',
                                  message: res.result.errorMsg
                              });
                              that.isSub=false;
                            }
                        }
                    })  
            },
        },
        mounted() {
          this.getCompanyList(); //所属机构
          this.handleChange();//省市区
          this.request();
        },
   });

 </script>

@endsection